#!/bin/bash

IP=`ifconfig $1 | grep "inet addr" | gawk -F: '{print $2}' | gawk '{print $1}'`
echo $IP
IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth0 |awk -F= '{print $2}'`
echo $IP
IP=` ifconfig eth0 |grep "inet addr" |awk '{print $2}' |awk -F: '{print $2}'`
echo $IP

cp /etc/my.cnf /etc/my.cnf.original.mc++

sed "/old_passwords=1/ a port=3306"  \
	/etc/my.cnf         > /etc/my.cnf.mc++.01
sed "/old_passwords=1/ a bind-address=$IP" \
	/etc/my.cnf.mc++.01 > /etc/my.cnf.mc++.02
cat /etc/my.cnf.mc++.02

/bin/cp -f /etc/my.cnf.mc++.02 /etc/my.cnf
service mysqld restart

MYSQL="mysql -u root -peLaStIx.2oo7"
$MYSQL -e "show databases;"
$MYSQL -e "use asterisk; show tables;"
$MYSQL -e "use asterisk; select * from sip;"
$MYSQL -e "use asterisk; select * from iax;"
 
$MYSQL "update db set Host='"$IP"' where Db='asterisk';"
$MYSQL "update user set Host='192.168.102.191' where user='root';"
; ERROR 1102 (42000): Incorrect database name 'update db set Host='192.168.0.36' where Db='asterisk';'
; ERROR 1102 (42000): Incorrect database name 'update user set Host='192.168.102.191' where user='root';'
